package com.qfedu.fy.controller;

import com.qfedu.fy.util.CodeImgUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * ......................我佛慈悲......................
 * _oo0oo_
 * o8888888o
 * 88" . "88
 * (| -_- |)
 * 0\  =  /0
 * ___/`---'\___
 * .' \\|     |// '.
 * / \\|||  :  |||// \
 * / _||||| -卍-|||||- \
 * |   | \\\  -  /// |   |
 * | \_|  ''\---/''  |_/ |
 * \  .-\__  '-'  ___/-. /
 * ___'. .'  /--.--\  `. .'___
 * ."" '<  `.___\_<|>_/___.' >' "".
 * | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 * \  \ `_.   \_ __\ /__ _/   .-` /  /
 * =====`-.____`.___ \_____/___.-`___.-'=====
 * `=---='
 * ..............佛祖保佑无BUG..................
 *
 * @author mxj
 * @date 2022/6/16 19:20
 */
@Controller
public class IndexController{
    @GetMapping("/api/img/code.do")
    public void creat(HttpServletResponse response, HttpSession session) throws IOException {
        String code = CodeImgUtil.createCode(4);
        session.setAttribute("code",code);
        ImageIO.write(CodeImgUtil.createImg(code),"png",response.getOutputStream());
    }
}
